<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport"
        content="width=device-width, initial-scale=1.0">
<meta name="HandheldFriendly" content="true">
<title>Sample</title>
</head>
<body>
<script>
   document.write("当前模式：" + (navigator.onLine ? "在线" : "脱机"));
</script>
</body>
</html>